/*
 *******************************************************************************
 *
 * Copyright (C) 2019-2020 Dialog Semiconductor.
 * This computer program includes Confidential, Proprietary Information
 * of Dialog Semiconductor. All Rights Reserved.
 *
 *******************************************************************************
 */

package com.dialog.suotalib.interfaces;

import com.dialog.suotalib.global.SuotaProfile;
import com.dialog.suotalib.interfaces.callbacks.ISuotaManagerCallback;

/**
 * Interface your activity needs to implement in order for you to use {@link com.dialog.suotalib.suota.AutoSuota}
 */
public interface IBaseSuota {
    /**
     * Gets triggered when the {@link ISuotaManagerCallback#onDeviceReady()}
     * callback gets triggered.
     */
    void startSuota();

    /**
     * Gets triggered when the {@link ISuotaManagerCallback#onSuotaLog(SuotaProfile.SuotaProtocolState, ISuotaManagerCallback.SuotaLogType, String)}
     * callback gets triggered.
     *
     * @param log the string param of the associated callback
     */
    void appendToLogcat(String log);

    /**
     * Gets triggered when the {@link com.dialog.suotalib.interfaces.callbacks.ISuotaManagerCallback#onSuccess(double, double)}
     * callback gets triggered.
     *
     * @param totalElapsedSecs       the total elapsed millis while suota was running
     * @param imageUploadElapsedSecs the total elapsed millis while the actual image was being sent
     */
    void onSuccess(double totalElapsedSecs, double imageUploadElapsedSecs);

    /**
     * Gets triggered when the {@link com.dialog.suotalib.interfaces.callbacks.ISuotaManagerCallback#onChunkSend(int, int, int, int, int, int)}
     * callback gets triggered.
     *
     * @param chunkCount chunk count of total chunks
     * @param totalChunks total chunks
     * @param chunk chunk count of current block
     * @param block block count
     * @param blockChunks total chunks in current block
     * @param totalBlocks total blocks
     */
    void updateCurrentlySendingInfo(int chunkCount, int totalChunks, int chunk, int block, int blockChunks, int totalBlocks);

    /**
     * Gets triggered when the {@link com.dialog.suotalib.interfaces.callbacks.ISuotaManagerCallback#onUploadProgress(float)}
     * callback gets triggered.
     *
     * @param percent the float param of the callback
     */
    void updateProgress(float percent);

    /**
     * Gets triggered when the {@link ISuotaManagerCallback#onRebootSent()}
     * callback gets triggered.
     */
    void rebootSent();

    /**
     * Gets triggered when the {@link com.dialog.suotalib.interfaces.callbacks.ISuotaManagerCallback#onFailure(int)}
     * callback gets triggered.
     *
     * @param errorSuotaLibCode one of the error code found within {@link com.dialog.suotalib.global.SuotaProfile.Errors}
     */
    void displayErrorDialog(int errorSuotaLibCode);

    /**
     * Overload of the above method.
     *
     * @param errorMsg string error message
     */
    void displayErrorDialog(String errorMsg);

    /**
     * Gets triggered when the {@link com.dialog.suotalib.interfaces.callbacks.ISuotaManagerCallback#onConnectionStateChange(SuotaProfile.SuotaManagerStatus)}
     * callback gets triggered due to Gatt Disconnection.
     */
    void deviceDisconnected();

    /**
     * Gets triggered when the Suota has finished, either right after {@link #onSuccess(double, double)} or {@link #rebootSent()}
     * depending on the value of auto send reboot.
     */
    void onSuotaFinished();

    /**
     * Gets triggered when the config {@link com.dialog.suotalib.global.SuotaLibConfig#CALCULATE_STATISTICS} is set to true,
     * every 500ms, in order to inform the library user about the transfer speed statistics until the time it got triggered.
     *
     * @param current current block speed (bytes per second)
     * @param max max block speed (bytes per second)
     * @param min min block speed (bytes per second)
     * @param avg average speed (bytes per second)
     */
    void updateSpeedStatistics(double current, double max, double min, double avg);
}
